<!DOCTYPE html>

<html lang="en">

<head>

    <meta charset="UTF-8">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta http-equiv="X-UA-Compatible" content="ie=edge">

    <title>Document</title>

</head>

<body>

    <script>

        var p=new Promise((resolve,reject)=>{

            resolve("data from p");

 

        });

        p.then(data=>{

            console.log(data);

            return "hellodata";

        }).then(function(data){

            console.log(data);

            // resolve("hello"+data);

            // return "hello"+data;

            return new Promise((resolve,reject)=>{resolve("hello"+data);})

        }).then(function(data){setTimeout(console.log,3000,data);}).catch(error=>{console.log(error)});//catch捕获错误

    </script>

</body>

</html>